<script lang="ts">
import { defineComponent, computed } from 'vue'
export default defineComponent({
  props: {
    name: {
      type: String,
      required: true
    },
    color: {
      type: String,
      default: ''
    }
  },
  setup(props) {
    return {
      iconName: computed(() => `#icon-${props.name}`)
    }
  }
})
</script>

<template>
  <div class="svg-icon-wrap">
    <svg aria-hidden="true" class="svg-icon" :style="{ color }">
      <use :xlink:href="iconName" :fill="color" />
    </svg>
  </div>
</template>

<style scope lang="less">
.svg-icon-wrap {
  display: inline-block;
}

.svg-icon {
  display: flex;
  align-items: center;
  width: 1em;
  height: 1em;
  fill: currentcolor;
}
</style>
